package work.jame.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import work.jame.blog.pojo.UserWallpaperRelation;
import work.jame.blog.mapper.UserWallpaperRelationMapper;
import work.jame.blog.service.UserWallpaperRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Jame
 * @since 2023-05-26
 */
@Service
public class UserWallpaperRelationServiceImpl extends ServiceImpl<UserWallpaperRelationMapper, UserWallpaperRelation> implements UserWallpaperRelationService {

    @Override
    public boolean queryUserHaveWallpaper(Long userId, Long wallpaperId) {
        QueryWrapper<UserWallpaperRelation> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId)
                .eq("wallpaper_id", wallpaperId);
        return this.count(wrapper) == 1;
    }
}
